use std::io;

fn main() {
    // let mut input = String::new();
    // let _ = io::stdin().read_line(&mut input).unwrap();

    // let _n = input.trim().parse::<i32>().unwrap();
    // input.clear();
    // let _ = io::stdin().read_line(&mut input);
    // let newvec: Vec<i32> = input.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect();

    // let mut sum = 0;
    // for i in 0..newvec.len() {
    //     sum += newvec[i];
    //     print!("{} ", sum);
    // }
    // println!("");

    // let mut mat: Vec<Vec<i32>>;
    let mut input = String::new();
    let _ = io::stdin().read_line(&mut input).unwrap();
    let mut parts = input.trim().split_whitespace();
    let m = parts.next().unwrap().parse::<usize>().unwrap();
    let n = parts.next().unwrap().parse::<usize>().unwrap();
    let mut mat = vec![vec![0; n]; m];
    input.clear();
    for i in 0..m{
        let _ = io::stdin().read_line(&mut input).unwrap();
        mat[i] = input.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect();
        input.clear();
    }
    let mut res: Vec<Vec<i32>> = vec![vec![0;n];m];
    for i in 0..m {
        for j in 0..n {
            res[i][j] = 0;
        }
    }
    for j in 0..n {
        for k in 0..j+1 {
            res[0][j] = res[0][j] + mat[0][k];
        }
    }
    for i in 1..m {
        res[i][0] = res[i-1][0] + mat[i][0];
        for j in 1..n {
            res[i][j] = res[i-1][j] + mat[i][j] + res[i][j-1] - res[i-1][j-1];
        }
    }
    for i in 0..m {
        for j in 0..n {
            print!("{} ", res[i][j]);
        }
        println!("");
    }
}
